<?
include_once '../library.php';
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<title>SK Communications A11Y Score Board</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- Bootstarap Version -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="../bootstrap/js/bootstrap.js"></script>
<link type="text/css" rel="stylesheet" href="../bootstrap/css/bootstrap.css" />
<!-- //Bootstarap Version -->
<script type="text/javascript" src="../js/common.js"></script>
<!-- Basic Style -->
<link type="text/css" rel="stylesheet" href="../css/style.css" />
<!-- //Basic Style -->
</head>
<body>
<?
$table_name = "service_url";
$select_array = array("*");
$url_nate = array();
$url_cyworld = array();
$service_url = selectDB($table_name, $select_array, "1=1 ORDER BY flag DESC, rank ASC");

/* URL Categoriging */
for($i=0; $i<count($service_url); $i++){
	if($service_url[$i]['category'] == 'n'){
		array_push($url_nate, $service_url[$i]);
	}else{
		array_push($url_cyworld, $service_url[$i]);
	}
}


for($i=0;$i<count($url_nate);$i++){
	$idx = $url_nate[$i]['idx'];
	$title = $url_nate[$i]['title'];
	$url = $url_nate[$i]['url'];
	$rank = $url_nate[$i]['rank'];
	$flag = $url_nate[$i]['flag'];
	
	if($flag == "0"){
		$trClass="error";
	}else{
		$trClass="";
	}
	$print_item_nate = $print_item_nate."
		<tr class=\"$trClass\">
			<td><input type=\"hidden\" value=\"$idx\" name=\"data[]\"><input type=\"text\" value=\"$title\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$url\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$rank\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$flag\" name=\"data[]\"></td>
		</tr>
	";
}

for($k=0;$k<count($url_cyworld);$k++){
	$idx = $url_cyworld[$k]['idx'];
	$title = $url_cyworld[$k]['title'];
	$url = $url_cyworld[$k]['url'];
	$rank = $url_cyworld[$k]['rank'];
	$flag = $url_cyworld[$k]['flag'];
	
	if($flag == "0"){
		$trClass="error";
	}else{
		$trClass="";
	}
	
	$print_item_cyworld = $print_item_cyworld."
		<tr class=\"$trClass\">
			<td><input type=\"hidden\" value=\"$idx\" name=\"data[]\"><input type=\"text\" value=\"$title\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$url\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$rank\" name=\"data[]\"></td>
			<td><input type=\"text\" value=\"$flag\" name=\"data[]\"></td>
		</tr>
	";
}

?>
<div id="wrap">
	<div class="contents">
		<div class="navWrap">
			<h3>SK Communications A11Y - ADMIN</h2></h3>
		</div>
		<ul class="nav nav-tabs" id="serviceTab">
			<li><a href="#nate" data-toggle="tab"><img src="/tools/a11y/img/tab_nate.png" alt="NATE" /></a></li>
			<li><a href="#cyworld" data-toggle="tab"><img src="/tools/a11y/img/tab_cyworld.png" alt="CYWORLD" /></a></li>
		</ul> 		
		<div class="tab-content">
			<div class="tab-pane active" id="nate">
				<form action="/tools/a11y/admin/db_service_write.php" name="nate" method="POST">
				<input type="hidden" name="category" value="n" />
				<table class="table table-bordered admin-url" id="nateItem">
					<thead>
						<tr class="navbar-inner">
							<th>타이틀</th>
							<th>주소</th>
							<th>순서</th>
							<th>표시</th>
						</tr>
					</thead>
					<?=$print_item_nate?>
				</table>
				<button type="button" class="btn btn-warning" onclick="addItem('nateItem')">추가</button>
				<button type="submit" class="btn btn-primary">저장</button>
				</form>
			</div>
						
			<div class="tab-pane" id="cyworld">
				<form action="/tools/a11y/admin/db_service_write.php" name="cyworld" method="POST">
				<input type="hidden" name="category" value="c" />
				<table class="table table-bordered admin-url" id="cyworldItem">
					<thead>
						<tr class="navbar-inner">
							<th>타이틀</th>
							<th>주소</th>
							<th>순서</th>
							<th>표시</th>
						</tr>
					</thead>
					<?=$print_item_cyworld?>
				</table>		
				<button type="button" class="btn btn-warning" onclick="addItem('cyworldItem')">추가</button>
				<button type="submit" class="btn btn-primary">저장</button>
				</form>
			</div>
		</div>
	<div>
</div>
<div class="footer">2013. SK Communications | UI Dev Team</div>
<script type="text/javascript">

function addItem(tObj){
	var tObj = "#"+tObj;
	
	var rItem = '<tr class="warning"><td><input type="hidden" value="new" name="data[]"><input type="text" name="data[]"></td><td><input type="text" name="data[]"></td><td><input type="text" name="data[]"></td><td><input type="text" value="1" name="data[]"></td></tr>';
	$(tObj).append(rItem);
}

$('#serviceTab a').click(function (e) {
	e.preventDefault();
	$(this).tab('show');
})

$('#serviceTab a:first').tab('show');
</script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-39065309-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</body>
</html>
